package com.winbomb.simulife.game.screens;

import com.winbomb.simulife.Master;
import com.winbomb.simulife.framework.Game;
import com.winbomb.simulife.framework.Screen;
import com.winbomb.simulife.framework.Input.TouchEvent;
import com.winbomb.simulife.game.Assets;
import com.winbomb.simulife.game.GameScreen;
import com.winbomb.simulife.game.TouchArea;

public class SelectUniversityScreen extends Screen {

	final TouchArea pageUpArea = new TouchArea(60, 440, 75, 23);
	final TouchArea pageDownArea = new TouchArea(170, 440, 75, 23);
	final TouchArea mainArea = new TouchArea(10, 30, 300, 400);

	boolean pageUpEnabled;
	boolean pageDownEnabled;

	public SelectUniversityScreen(Game game) {
		super(game);

		pageUpEnabled = false;
		pageDownEnabled = false;
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub

	}

	@Override
	public void present(float deltaTime) {
		g.drawPixmap(Assets.select_university, 0, 0);
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(float deltaTime) {
		updateTouchEvents();

		for (TouchEvent event : touchEvents) {
			if (event.type != TouchEvent.TOUCH_UP) {
				continue;
			}

			if (mainArea.isBound(event)) {
				int idx = getSelectedIndex(event.x, event.y);

				// 设置学校

				// 返回
				game.getWorld().nextEvent();
				game.setScreen(new GameScreen(game));
			} else if (pageUpEnabled && pageUpArea.isBound(event)) {

			} else if (pageDownEnabled && pageDownArea.isBound(event)) {

			}
		}
	}

	private int getSelectedIndex(int x, int y) {
		return (y - 30) / 50;
	}

}
